/**
 * 复选框
 * <icheck>
 * <icheck checkboxStyle='icheckbox_flat-red' radioStyle='iradio_flat-red'>
 */
app.directive('icheck', function() {
	return {
		link: function(scope, element, attrs) {
			angular.element(element).iCheck({
				checkboxClass: (attrs.checkboxstyle == undefined || attrs.checkboxstyle == ''?'icheckbox_square-blue':attrs.checkboxstyle),
				radioClass: (attrs.radiostyle == undefined || attrs.radiostyle == ''?'iradio_square-blue':attrs.radiostyle)
			});
			//全选
			$('.checkall').on('ifChecked ifUnchecked', function(event) {
		        if (event.type == 'ifChecked') {
		            $(this).closest('table').find('input[type=checkbox]').iCheck('check');
		        } else {
		            $(this).closest('table').find('input[type=checkbox]').iCheck('uncheck');
		        }
		    });
		}
	}
});

/**
 * 下拉菜单
 */
app.directive('dropdownDirective', function() {
	return {
		restrict: 'A',
		link: function(scope, element, attrs) {
			angular.element('.dropdown-toggle').dropdownHover();

			angular.element('.dropdown-slimscroll').slimScroll({
				"height": '250px',
				"wheelStep": 30
			});
		}
	}
});

/**
 * 动画
 */
app.directive('animations', function() {
	return  {
		restrict: 'A',
		link: function(scope, element, attrs) {
			angular.element('button').on('click', function() {
				var ani = $(this).attr('data-value');
        		$("#page-wrapper").addClass("animated " + ani);
			});
		}
	}
})
